<template>
	<div class="public-table">
		<el-table :data="tableData" border stripe>
			<template v-for="(item, index) in tableHeader">
				<!-- 判断是否有slot -->
				<el-table-column :align="item.align || 'center'" v-if="!item.slot" :width="item.width" :prop="item.prop" :label="item.label">
				</el-table-column>
				<el-table-column v-else :align="item.align || 'center'" :prop="item.prop" :label="item.label">
					<template slot-scope="{ row, $index }">
						<slot v-if="item.slot" :name="item.slot" :row="row" :index="$index"></slot>
					</template>
				</el-table-column>
			</template>
		</el-table>
	</div>
</template>

<script>
export default {
	name: "PublicTable",
	props: {
		tableData: {
			type: Array,
			required: true,
			default: () => [],
		},
		tableHeader: {
			type: Array,
			required: true,
			default: () => [],
		},
	},
	data() {
		return {};
	},

	mounted() {},

	methods: {},
};
</script>

<style lang="scss" scoped></style>
